<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>SHOP 管理中心 - 类型管理 </title>
<base href="__STATIC__/Admin/">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="styles/general.css" rel="stylesheet" type="text/css" />
<link href="styles/main.css" rel="stylesheet" type="text/css" />
<style>
	.tname:hover{
		background: #ccc;
	}
</style>
</head>
<body>

<h1>
<!-- <span class="action-span"><a href="{:url('Admin/Attribute/attr_list')}">属性列表</a></span> -->
<span class="action-span"><a href="{:url('Admin/GoodsType/GoodsType_add')}">新建商品类型</a></span>
<span class="action-span1"><a href="index.php?act=main">SHOP 管理中心</a> </span><span id="search_id" class="action-span1"> - 商品类型 </span>
<div style="clear:both"></div>
</h1>

<!-- start goods type list -->
<div class="list-div" id="listDiv">

	<table width="100%" cellpadding="3" cellspacing="1" id="listTable">
		<tbody>
			<tr>
				<th>商品类型名称</th>
				<th>属性分组</th>
				<th>状态</th>
				<th>操作</th>
			</tr>
			{foreach $list as $v}
			<tr>
				<td class="first-cell" align="center"><span class="tname" id="{$v.type_id}" title="点击修改">{$v.type_name}</span></td>
				<td align="center">{$v.attr_group}</td>
				<td align="center">
					{if condition="($v['is_show'] == 0)"}
			            <img src="images/no.gif" class="is_show" id="{$v.type_id}" title="点击修改">
			        {elseif condition="($v['is_show'] == 1)"/}
			            <img src="images/yes.gif" class="is_show" id="{$v.type_id}" title="点击修改">
			        {/if}	
				</td>
				<td align="center">
				  <a href="{:url('Admin/Attribute/attr_list')}" title="属性列表">属性列表</a> |
				  <a href="javascript:;" title="移除" class="sc" id="{$v.type_id}">移除</a>
				</td>
			</tr>
			{/foreach}
  </tbody></table>
 <div>{$list->render()}</div>
</div>
<!-- end goods type list -->

<div id="footer">
	版权所有 &copy; 2006-2013 软工教育 - 高级PHP - </div>
</div>

</body>
<script src="jquery.js"></script>
<script>

	$(".tname").on('click',function(){
		var td = $(this).parent();
		var id = $(this).attr('id');
		var tname = $(this).text();
		td.children().html('<input type="text" id="input">');
		$('#input').val('').focus().val(tname);
		$('#input').blur(function(event) {
			var text = $(this).val();
			td.children().html('<span class="tname" id="'+id+'">'+text+'</span>');
			 $.ajax({
	          url: "{:url('Admin/GoodsType/GoodsType_save')}",
	          type: 'get',
	          dataType: 'json',
	          data: {id:id,tname:text},
	          success:function(e){
		          if (!e) {
		             history.go(0);
		          }
	          }
	        })
		});
	});

	$(".is_show").click('click',function(){
			 var src = $(this).attr('src');
		       if (src=='images/yes.gif') {
			        $(this).attr('src','images/no.gif');
			        var is_show=0;
		       }else{
			        $(this).attr('src','images/yes.gif');
			        var is_show=1;
		       }
		       var id=$(this).attr('id');
		       $.ajax({
		         url: "{:url('Admin/GoodsType/GoodsType_show')}",
		         type: 'get',
		         dataType: 'json',
		         data: {id:id,is_show:is_show},
		         success:function(e){
		      		if (e===false) {
				        history.go(0);
				    }
		         }
		       })
		});

	$(".sc").on('click',function(){
          var id = $(this).attr('id');
          $.ajax({
              url:"{:url('Admin/GoodsType/GoodsType_del')}",
              type:"get",
              data:{id:id},
              dataType:'json',
              success:function(e){
                if(e.code==1){
                    alert(e.msg);
                    history.go(0)
                }else if(e.code==0){
                    alert(e.msg);
                    history.go(0)
                }else if(e.code==2){
                	alert(e.msg);
                    history.go(0)
                }
              }
          });
      });
</script>
</html>